/*
 * Point2D.cpp
 *
 *  Created on: Apr 14, 2009
 *      Author: wrice
 */

#include "MyVideoTrace.h"
namespace MyVideoTrace {


Point2D::Point2D(int x, int y) : x_(x), y_(y) {
}

Point2D::~Point2D() {
}

int Point2D::getX() const {
	return x_;
}
int Point2D::getY() const {
	return y_;
}

bool Point2D::operator==(const Point2D & rhs) const {
	return getX() == rhs.getX() && getY() == rhs.getY();
}

Point2D Point2D::operator+(const Point2D & rhs) const {
	return Point2D( getX() + rhs.getX(), getY() + rhs.getY() );
}

Point2D Point2D::operator-(const Point2D & rhs) const {
	return Point2D( getX() - rhs.getX(), getY() - rhs.getY() );
}

Point2D Point2D::operator/(int dinominator) const {
	return Point2D( getX() / dinominator, getY() / dinominator );
}

Point2D Point2D::operator*(int multi) const {
	return Point2D( getX() * multi, getY() * multi );
}

ostream &operator<<(ostream &stream, Point2D rhs) {
	stream << "Point2D::[ x = " << rhs.getX() << ", y = " << rhs.getY() << " ]";
	return stream;
}

float Point2D::distance( Point2D rhs ) const {
	const int diffX = getX() - rhs.getX();
	const int diffY = getY() - rhs.getY();
	return sqrt( diffX * diffX + diffY * diffY );
}

}
